package adv7;

import java.lang.reflect.Method;

/**
 * @author oldliu
 * @since 1.0
 */
public class CalcTest {
    public static void main(String[] args) throws  Exception {
        Calc c=new Calc();
        //反射调用
        Class<? extends Calc> cls = c.getClass();
        Method mthd = cls.getDeclaredMethod("mul", int.class, int.class);
        //方法上，有没有Test这个注解
        if(mthd.isAnnotationPresent(Test.class)){
            Test test = mthd.getAnnotation(Test.class);
            System.out.println(test.before());
            Object r = mthd.invoke(c, 1000, 200);
            System.out.println("结果是："+r);
            System.out.println(test.after());
        }else{
            Object r = mthd.invoke(c, 1000, 200);
            System.out.println("结果是："+r);
        }

//        int r1 = c.add(10, 20);
//        System.out.println(r1);
//        int r2=c.div(102,20);
//        System.out.println(r2);
    }
}
